#ifndef __RANGE_CONTAINER_H
#define __RANGE_CONTAINER_H

#pragma once

#include <limits>

class CRangeContainer
{
public:
	typedef uint8 RangeID;

	struct SRange
	{
		SRange(float rangeSq, const char* szEnterSignal, const char* szLeaveSignal) :
			state(Outside),
			rangeSq(rangeSq),
			enterSignal(szEnterSignal),
			leaveSignal(szLeaveSignal)
		{
		}

		SRange() : rangeSq(0.f), state(Outside) {}

		enum State
		{
			Inside,
			Outside
		};

		string enterSignal;
		string leaveSignal;
		float rangeSq;
		State state;
	};

	void Update(CPuppet* pPuppet);
	RangeID AddRange(const SRange& range);

	void ResetRanges()
	{
		m_ranges.clear();
	}

	const SRange* GetRange(RangeID id) const
	{
		assert(id < m_ranges.size());
		return (id < m_ranges.size()) ? &m_ranges[id] : NULL;
	}

	void ChangeRange(RangeID id, float distance)
	{
		assert(id < m_ranges.size());

		if (id < m_ranges.size())
		{
			m_ranges[id].rangeSq = square(distance);
		}
	}

private:
	typedef std::vector<SRange> Ranges;
	Ranges m_ranges;
};

#endif	// #ifndef __RANGE_CONTAINER_H
